<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/6
 * Time: 16:04
 */

namespace app\admin\model\user;


use app\common\library\Auth;
use think\Exception;
use think\Model;

class UserExpertsAccessory extends Model
{

    protected $table = 'fa_user_experts_accessory';
    protected $auth;

    public function __construct($data = [])
    {
        $this->auth = Auth::instance();

        parent::__construct($data);
    }

    public function addAll($params = [])
    {
        if (is_array($params) && (count($params) > 0)) {
            $data = [];
            foreach ($params as $key => $val) {
                $data[] = [
                    'uid' => $this->auth->id,
                    'ua_id' => $val['file_id'],
                    'title' => $val['title']
                ];
            }
            try {
                $this->save($data);
            } catch (Exception $exception) {

            }

        }
    }

}